const app = getApp();
const { getStorageItem } = require('../../../../utils/storage');

Component({
  /**
   * 组件的属性列表
   */
  properties: {},
  /**
   * 组件的初始数据
   */
  data: {
    // isShowAppPic: false, //展示app提现宣传页
    funcList: [
      {
        id: 'func_14',
        name: '婚品商城',
        iconUrl: 'https://ustatic.joymew.com/joymewAssistant/hb/mallIcon.png',
        pageUrl: '/pages/activity/shop/shop',
        subtitle: 'New',
      },
      {
        id: 'func_1',
        name: '主持风采',
        iconUrl: '/assets/icon/hosting-style.svg',
        pageUrl: '/subpkg/pages/hosting-style/hosting-style',
      },
      {
        id: 'func_2',
        name: '问卷调查',
        icon: 'question',
        code: 'question',
      },
      {
        id: 'func_11',
        name: '备婚调研',
        icon: 'question',
        code: 'question_new',
      },
      {
        id: 'func_3',
        name: '邀请好友',
        icon: 'invite',
        code: 'invite',
        // opentype: "share",
        // subtitle: '享好礼',
      },
      {
        id: 'func_4',
        name: '实名认证',
        icon: 'auth',
        code: 'auth',
      },

      // {
      //   id: 'func_5',
      //   name: '小游戏',
      //   icon: 'game',
      //   code: 'game',
      //   subtitle: '赢现金',

      // },
      {
        id: 'func_6',
        name: '创建活动',
        icon: 'apply',
        code: 'apply',
      },
      {
        id: 'func_7',
        name: '合伙人',
        icon: 'partaner',
        code: 'partaner',
        // hidden: true
      },
      // {
      //   id: 'func_8',
      //   name: '酒吧代理',
      //   icon: 'bar',
      //   code: 'bar',
      //   // hidden: true
      // },
      // {
      //   id: 'func_9',
      //   name: '提现',
      //   icon: 'withdraw',
      //   code: 'withdraw',
      //   subtitle: '秒到账',

      //   // hidden: true
      // },
      // {
      //   id: 'func_10',
      //   name: '邀请',
      //   icon: 'invite',
      //   code: 'inviteTest',
        // subtitle: 'New',
        // hidden: true
      // },
      // {
      //   id: 'func_12',
      //   name: 'Wedding Rite',
      //   icon: 'yuehun',
      //   code: 'yuehun',
      //   subtitle: 'New',
      // },
      {
        id: 'func_13',
        name: '营销获客',
        iconUrl: '/assets/icon/marketing.png',
        code: 'marketing',
      },
      {
        id: 'func_14',
        name: '互动教程',
        iconUrl: 'https://ustatic.joymew.com/joymewH5/img/miji.png',
        pageUrl: '/subpkgActivity/pages/videoTeach/index/index',
      },
    ],
  },
  lifetimes: {
    attached() {
      this.hostStyleHiddenLogic();
    },
  },
  /**
   * 组件的方法列表
   */
  methods: {
    hostStyleHiddenLogic() {
      const storageUserId = wx.getStorageSync('userId');
      const TARGET_USERID = '6cabbf07fe484b3ca41c683c2f323a3b';
      if (storageUserId === TARGET_USERID) {
        const tmpFuncList = this.data.funcList;
        tmpFuncList.splice(0, 2);
        this.setData({
          funcList: tmpFuncList,
        });
      }
    },
    execFunc(e) {
      const { code, pageUrl } = e.currentTarget.dataset;
      if (pageUrl) {
        wx.navigateTo({
          url: pageUrl,
        });
        return;
      }

      const codeMap = {
        schedule: this.showPersonalCalender,
        question: this.showQuestionnaire,
        question_new: this.showNewQuestionnaire,
        auth: this.toAuth,
        bar: this.toBar,
        game: this.toRunGame,
        invite: this.toFriend,
        apply: this.toApplyActivity,
        partaner: this.toPartner,
        // withdraw: this.showAppModal,
        inviteTest: this.toInvite,
        yuehun: this.toYueHun,
        marketing: this.toGetPerson,
      };

      if (codeMap[code]) {
        codeMap[code].call(this);
      }
    },
    // 跳转约婚配置页面
    toYueHun() {
      wx.navigateTo({
        url: '/pages/home/yuehun/yuehun',
      });
    },
    toApplyActivity() {
      wx.navigateTo({
        url: '/pages/index/applyActivity/applyActivity',
      });
    },
    //前往个人档期资料
    showPersonalCalender() {
      wx.navigateTo({
        url: '/pages/calendar/personalDetail/p',
      });
    },
    // 前往问卷调查
    showQuestionnaire() {
      wx.navigateTo({
        url: '/pages/questionaire/main',
      });
    },
    // 前往新版问卷调查
    showNewQuestionnaire() {
      wx.navigateToMiniProgram({
        appId: 'wx2abb05870f1ba4c7',
        path: '/pages/survey',
        extraData: {},
        envVersion: 'release', // 打开正式版
        success(res) {
          // 打开成功
        },
        fail: function (err) {},
      });
    },
    toAuth() {
      wx.navigateTo({
        url: '/pages/identification/identification',
      });
    },
    toRunGame() {
      wx.showModal({
        title: `提示`,
        content: `请下载嗨喵App参与小游戏`,
        confirmText: '去下载',
        success: (res) => {
          if (res.confirm) {
            const banner = `https://mp.weixin.qq.com/s/oQc3zN78iUHiRFUBzPIaMw`;
            wx.navigateTo({
              url: `/pages/index/bannerLink/bannerLink?banner=${banner}`,
            });
          }
        },
        fail: (err) => {},
      });
    },
    toFriend() {
      wx.navigateTo({
        url: '/pages/invite/invite',
      });
    },
    toInvite() {
      wx.navigateTo({
        url: '/pages/inviteTest/inviteTest',
      });
    },
    toBar() {
      wx.navigateTo({
        url: '/pages/home/barAgent/barAgent',
      });
    },
    toPartner() {
      wx.navigateTo({
        url: '/pages/home/partner/partner',
      });
    },
    // 跳转我的红包
    toMyredpacket() {
      wx.navigateTo({
        url: '/pages/hb/hb',
      });
    },
    /**
     * 显示App下载地址
     */
    // showAppModal() {
    //   this.setData({
    //     isShowAppPic: true,
    //   });
    // },
    /**
     * 关闭App下载地址
     */
    // closeAppModal() {
    //   this.setData({
    //     isShowAppPic: false,
    //   });
    // },
    toGetPerson() {
      wx.navigateTo({
        url: '/pages/home/getPerson/myCard/myCard',
      });
    },
  },
});
